package com.woniuxy01;

import javax.swing.*;
import java.util.Scanner;

/**
 * @author 作者
 * @create 2025-05-28 9:29
 */
public class Test01 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("输入人数");
        int personNums = sc.nextInt();
        System.out.println("输入倒霉数字");
        int unluckyNum = sc.nextInt();
        int count=0;
        boolean[] persons = new boolean[personNums];
        for (int i = 0; i < personNums; i++) {
            persons[i] = true;
        }
        //循环若干轮
        do{
            //每轮循环报数
            for(int i=0;i<persons.length;i++){
                //没有被淘汰，参与报数
                if(persons[i]){
                    count++;
                    //判断是否要被淘汰
                    if(count%unluckyNum==0){
                        persons[i]=false;
                        personNums--;
                    }
                }
            }
            if(personNums==1){
                break;
            }
        }while (true);

        for (int i = 0; i < persons.length; i++) {
            if(persons[i]){
                System.out.println(i);
            }
        }
    }
}
